Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fusdc uses bech32 address hook encoding #10682

Merged
merged 2 commits into from
Dec 13, 2024
Merged

Conversation

0xpatrickdev
Copy link
Member

@0xpatrickdev 0xpatrickdev commented Dec 11, 2024

refs: #10614

Description

  • @agoric/fast-usdc uses bech32 encoded address hooks via decodeAddressHook and encodeAddressHook

Security Considerations

None

Scaling Considerations

None

Documentation Considerations

None

Testing Considerations

Updates existing tests. Adds an additional test that shows Advancer forbids extra query parameters

Upgrade Considerations

None, unreleased code

Copy link

cloudflare-workers-and-pages bot commented Dec 11, 2024

Deploying agoric-sdk with  Cloudflare Pages  Cloudflare Pages

Latest commit: 6091992
Status: ✅  Deploy successful!
Preview URL: https://530bd9a4.agoric-sdk.pages.dev
Branch Preview URL: https://pc-fusdc-bech32-hooks.agoric-sdk.pages.dev

View logs

Comment on lines 35 to 36
const hardenOrFreeze =
harden && typeof harden === 'function' ? harden : Object.freeze;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since harden may not be defined,

Suggested change
const hardenOrFreeze =
harden && typeof harden === 'function' ? harden : Object.freeze;
const hardenOrFreeze = typeof harden === 'function' ? harden : Object.freeze;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks these changes are now in #10683

@0xpatrickdev 0xpatrickdev force-pushed the pc/fusdc-bech32-hooks branch 3 times, most recently from a3ba2d1 to f081d9f Compare December 11, 2024 23:10
@0xpatrickdev 0xpatrickdev changed the base branch from master to mfig-no-future-address-hooks December 11, 2024 23:10
EudParamShape,
);
const decoded = decodeAddressHook(recipientAddress);
mustMatch(decoded, AddressHookShape);
Copy link
Member Author

@0xpatrickdev 0xpatrickdev Dec 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we check that cctpTxEvidence contains the correct settlementAccountAddress anywhere. At one point I thought this was a concern of the EventFeed, but maybe this is the better place to do it.

To avoid increasing scope of this PR, I'll tackle this in a follow up

@0xpatrickdev 0xpatrickdev marked this pull request as ready for review December 11, 2024 23:33
@0xpatrickdev 0xpatrickdev requested a review from a team as a code owner December 11, 2024 23:33
@Agoric Agoric deleted a comment from mergify bot Dec 12, 2024
Copy link
Member

@dckc dckc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, this should work.

The comments are mostly one style suggestion that shows up in several places.

Comment on lines 43 to 45
const encodedAddr = encodeAddressHook(agoricAddr, {
EUD: destination,
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor style point: I'd much rather see:

Suggested change
const encodedAddr = encodeAddressHook(agoricAddr, {
EUD: destination,
});
const encodedAddr = encodeAddressHook(agoricAddr, { EUD });

with the arg renamed to EUD. Do we need 2 names for it?

console.log('no EUD parameter', tx.receiver);
return;
}
if (!matches(EUD, M.string())) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to go outside JS here.

Suggested change
if (!matches(EUD, M.string())) {
if (typeof EUD !== 'string') {

A pattern match for the whole return value of decodeAddressHook(...) would make sense.
Does @endo/patterns have a thing between matches() and mustMatch()? i.e. if this doesn't match, give me a good reason why not, not just a boolean false.

try {
const { EUD } = decodeAddressHook(tx.receiver).query;
if (!EUD) {
console.log('no EUD parameter', tx.receiver);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we want the tracer here, right?

Suggested change
console.log('no EUD parameter', tx.receiver);
log('no EUD parameter', tx.receiver);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was copied over but yes, updated

return;
}
if (!matches(EUD, M.string())) {
console.log('EUD is not a string', EUD);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
console.log('EUD is not a string', EUD);
log('EUD is not a string', EUD);

@@ -151,17 +151,23 @@ export const prepareSettler = (
return;
}

if (!addressTools.hasQueryParams(tx.receiver)) {
let endUserDestination;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why a separate name for it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

Comment on lines 359 to 362
{
EUD: 'osmo1234',
extra: 'value',
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe I shouldn't bother with these style nits, but... any particular reason to split this across 4 lines?

Suggested change
{
EUD: 'osmo1234',
extra: 'value',
},
{ EUD: 'osmo1234', extra: 'value' },

Comment on lines 388 to 390
const recipientAddress = encodeAddressHook(settleAddr, {
EUD,
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const recipientAddress = encodeAddressHook(settleAddr, {
EUD,
});
const recipientAddress = encodeAddressHook(settleAddr, { EUD });

Comment on lines 37 to 39
{
EUD: 'osmo183dejcnmkka5dzcu9xw6mywq0p2m5peks28men',
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feel free to ignore these, but they stick out at me:

Suggested change
{
EUD: 'osmo183dejcnmkka5dzcu9xw6mywq0p2m5peks28men',
},
{ EUD: 'osmo183dejcnmkka5dzcu9xw6mywq0p2m5peks28men' },

Comment on lines 60 to 62
{
EUD: 'dydx183dejcnmkka5dzcu9xw6mywq0p2m5peks28men',
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{
EUD: 'dydx183dejcnmkka5dzcu9xw6mywq0p2m5peks28men',
},
{ EUD: 'dydx183dejcnmkka5dzcu9xw6mywq0p2m5peks28men' },

Comment on lines 101 to 103
{
EUD: 'random1addr',
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{
EUD: 'random1addr',
},
{ EUD: 'random1addr' },

@0xpatrickdev 0xpatrickdev force-pushed the pc/fusdc-bech32-hooks branch 2 times, most recently from ba4fce5 to d369f08 Compare December 12, 2024 01:47
@michaelfig michaelfig force-pushed the mfig-no-future-address-hooks branch 2 times, most recently from a8a6172 to 80fee60 Compare December 12, 2024 23:47
Base automatically changed from mfig-no-future-address-hooks to master December 13, 2024 00:39
@0xpatrickdev 0xpatrickdev added the automerge:rebase Automatically rebase updates, then merge label Dec 13, 2024
@mergify mergify bot merged commit 254e849 into master Dec 13, 2024
91 checks passed
@mergify mergify bot deleted the pc/fusdc-bech32-hooks branch December 13, 2024 01:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge:rebase Automatically rebase updates, then merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants